package rlex.classes.program;

/*
 * IF COND THEN
 * 	COMMAND
 * ELSE
 * 	COMMAND
 */
public class CommandIf extends Command {
	private Expression cond;
	private Command command_then;
	private Command command_else;

	public Expression getCond() {
		return cond;
	}

	public void setCond(Expression cond) {
		this.cond = cond;
	}

	public Command getCommand_then() {
		return command_then;
	}

	public void setCommand_then(Command commandThen) {
		command_then = commandThen;
	}

	public Command getCommand_else() {
		return command_else;
	}

	public void setCommand_else(Command commandElse) {
		command_else = commandElse;
	}

	public String toString() {
		String ret = "";
		ret += "if (" + cond.toString() + ") then (";
		ret += command_then.toString();
		ret += ")";
		if (command_else != null) {
			ret += " else (";
			ret += command_else.toString();
			ret += ")";
		}
		return ret;
	}
	
	public void display(int level) {
		System.out.print("IF : ");
		cond.display(0);
		System.out.print("\nTHEN :\n");
		command_then.display(0);
		System.out.print("\nELSE :\n");
		command_else.display(0);
		System.out.print("\nEND\n");
		
	}

}
